<template>
    <div>
        <h1>老师添加界面</h1>
        <p>老师名字：<input type="text" v-model="name"></p>
        <p>密&emsp;&emsp;码：<input type="text" v-model="password"></p>
        <p>手&ensp;机&ensp;号：<input type="text" v-model="phone"></p>
        <el-button type="primary" @click="addteacher">添加</el-button>
    </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            name:'',     
            password:'',
            phone:'',
            base_url:'http://127.0.0.1:8000'        
      }
    },
    methods: {
        addteacher(){
            console.log(this.name,this.password,this.phone)
            let form_data = new FormData()
            form_data.append('name',this.name)
            form_data.append('password',this.password)
            form_data.append('phone',this.phone)
            axios({
                url:this.base_url + '/app01/teacher_api',
                method:'post',
                data:form_data
            }).then(res =>{
                 console.log(res.data)
                 alert(res.data.msg)
            })
        }
    },
    created() {

    }
}
</script>

<style scoped>

</style>
